import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

import beans.*;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

public class xtream {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		

		XStream xstream = new XStream(new DomDriver());
		xstream.alias("persona", Persona.class);
		xstream.alias("phonenumber", PhoneNumber.class);
//		
//		
//		XStream xstream = new XStream(new DomDriver());
//		xstream.alias("SolicitudCotizacion", BeanSolicitudCotizacion.class);
//		xstream.alias("ItemSolicitudCotizacion", BeanItemSolicitudCotizacion.class);
		
//		List<Persona> kids = new ArrayList<Persona>();
//		kids=agregarHijos(kids);
//		
//		
//		Persona joe = new Persona("Joe", "Walnes");
//		joe.setPhone(new PhoneNumber(123, "1234-456"));
//		//joe.setKids(kids);
//		joe.setFax(new PhoneNumber(123, "9999-999"));
//		
//		
//		
//		String xml = xstream.toXML(joe);
//		System.out.println(xml);
//		Persona martin =  (Persona)xstream.fromXML(new File("c:/ListaProv.xml"));
		
		
		try {
			
			Persona p = (Persona) xstream.fromXML(new FileInputStream("C://a.xml"));
			System.out.println(p.toString());
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	private static List<Persona> agregarHijos( List<Persona> kids) {
		Persona joe1 = new Persona("Joe1", "Walnes");kids.add(joe1);
		Persona joe2 = new Persona("Joe2", "Walnes");kids.add(joe2);
		Persona joe3 = new Persona("Joe3", "Walnes");kids.add(joe3);
		
		
		return kids;
	}

}
